package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbChatPage;
import com.ruoyi.system.service.ITbChatPageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * chatPageController
 * 
 * @author ruoyi
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/chatPage")
public class TbChatPageController extends BaseController
{
    @Autowired
    private ITbChatPageService tbChatPageService;

    /**
     * 查询chatPage列表
     */
    @RequiresPermissions("system:chatPage:list")
    @GetMapping("/list")
    public TableDataInfo list(TbChatPage tbChatPage)
    {
        startPage();
        List<TbChatPage> list = tbChatPageService.selectTbChatPageList(tbChatPage);
        return getDataTable(list);
    }

    /**
     * 导出chatPage列表
     */
    @RequiresPermissions("system:chatPage:export")
    @Log(title = "chatPage", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbChatPage tbChatPage)
    {
        List<TbChatPage> list = tbChatPageService.selectTbChatPageList(tbChatPage);
        ExcelUtil<TbChatPage> util = new ExcelUtil<TbChatPage>(TbChatPage.class);
        util.exportExcel(response, list, "chatPage数据");
    }

    /**
     * 获取chatPage详细信息
     */
    @RequiresPermissions("system:chatPage:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(tbChatPageService.selectTbChatPageByUserId(userId));
    }

    /**
     * 新增chatPage
     */
    @RequiresPermissions("system:chatPage:add")
    @Log(title = "chatPage", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbChatPage tbChatPage)
    {
        return toAjax(tbChatPageService.insertTbChatPage(tbChatPage));
    }

    /**
     * 修改chatPage
     */
    @RequiresPermissions("system:chatPage:edit")
    @Log(title = "chatPage", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbChatPage tbChatPage)
    {
        return toAjax(tbChatPageService.updateTbChatPage(tbChatPage));
    }

    /**
     * 删除chatPage
     */
    @RequiresPermissions("system:chatPage:remove")
    @Log(title = "chatPage", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(tbChatPageService.deleteTbChatPageByUserIds(userIds));
    }
}
